package search;

import vo.Program;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.select.Elements;

import java.io.IOException;
import java.util.UUID;

public class ParserImpl implements Parser {
    public Program parseHtml(String html, int i) {
        Program program = new Program();
        try {
            Document doc = Jsoup.connect(html).get();
            String id = UUID.randomUUID().toString();
            program.setId(id);
            program.setCountry("Hong Kong University");
            program.setUniversity("");
            program.setHomepage(html);
            program.setSchool(Message.list31.get(i));
            program.setProgramName(Message.list32.get(i));
            program.setDegree(Message.list33.get(i));
            program.setLocation("NULL");
            program.setPhoneNumber("NULL");

            Elements emails = doc.select("div.block-table-row");
            program.setEmail(emails.text());
            program.setDeadlineWithAid("NULL");
            program.setDeadlineWithoutAid("NULL");


        }catch(Exception e){}

        return program;
    }
}